import instance from '../../utils/request.js'

// 获取用户信息
export const getUserInfoAPI = (data) => {
  const { userId, role } = data
  return instance({
    url: `/api/users/${userId}`,
    method: 'POST',
    data: { role }
  })
}

// 修改用户头像
export const updateUserAvatarAPI = (data) => {
  const { userId, role, avatarUrl } = data
  return instance({
    url: `/api/users/${userId}/avatar`,
    method: 'POST',
    data: { role, avatarUrl }
  })
}

// 修改密码
export const updateUserPasswordAPI = (data) => {
  const { userId, role, oldPassword, newPassword } = data
  return instance({
    url: `/api/users/${userId}/updatepwd`,  
    method: 'POST',
    data: { role, oldPassword, newPassword }
  })
}